package com.demandbreakdown.xiyun.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.demandbreakdown.xiyun.model.entity.Picture;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

/**
 * 图片数据访问层
 *
 * @author poxz
 */
@Mapper
public interface PictureMapper extends BaseMapper<Picture> {

    /**
     * 增加浏览次数
     *
     * @param pictureId 图片ID
     */
    @Update("UPDATE picture SET view_count = view_count + 1 WHERE id = #{pictureId} AND is_delete = 0")
    void incrementViewCount(@Param("pictureId") Long pictureId);

    /**
     * 增加下载次数
     *
     * @param pictureId 图片ID
     */
    @Update("UPDATE picture SET download_count = download_count + 1 WHERE id = #{pictureId} AND is_delete = 0")
    void incrementDownloadCount(@Param("pictureId") Long pictureId);

    /**
     * 增加分享次数
     *
     * @param pictureId 图片ID
     */
    @Update("UPDATE picture SET share_count = share_count + 1 WHERE id = #{pictureId} AND is_delete = 0")
    void incrementShareCount(@Param("pictureId") Long pictureId);
}




